package com.glodon.paas.document.dao.domain;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.glodon.paas.document.api.bean.Revision;
import com.google.code.morphia.annotations.Entity;
import com.google.code.morphia.annotations.Id;

@Entity(value = "revision", noClassnameStored = true)
public class RevisionEntity {

    public static Revision getDto(RevisionEntity e) {
        if (e == null) {
            return null;
        } else {
            Revision d = new Revision();
            d.setId(e.getId());
            d.setDataBagId(e.getDataBagId());
            d.seteTag(e.geteTag());
            d.setFileSize(e.getFileSize());
            d.setPartsCount(e.getPartsCount());
            d.setRevisionNumber(e.getRevisionNumber());
            d.setStorageKey(e.getStorageKey());
            d.setTimestamp(e.getTimestamp());
            d.setFileId(e.getFileId());
            d.setCreator(e.getCreator());
            d.setUpdator(e.getUpdator());
            return d;
        }
    }

    public static List<Revision> getDtos(List<RevisionEntity> es) {
        if (es == null) {
            return null;
        } else {
            List<Revision> ds = new ArrayList<Revision>();
            for (RevisionEntity e : es) {
                ds.add(getDto(e));
            }
            return ds;
        }
    }

    @Id
    private String  id;

    private String  fileId;

    private Integer revisionNumber = 0;

    private Long    fileSize;

    private String  storageKey     = "";

    private Date    timestamp;

    private Integer partsCount     = 0;

    private String  eTag;

    private String  dataBagId;
    private String  creator;
    private String  updator;

    // private String thumbnailUrl;

    public String getFileId() {
        return fileId;
    }

    public void setFileId(String fileId) {
        this.fileId = fileId;
    }

    public Integer getRevisionNumber() {
        return revisionNumber;
    }

    public void setRevisionNumber(Integer revisionNumber) {
        this.revisionNumber = revisionNumber;
    }

    public Long getFileSize() {
        return fileSize;
    }

    public void setFileSize(Long fileSize) {
        this.fileSize = fileSize;
    }

    public String getStorageKey() {
        return storageKey;
    }

    public void setStorageKey(String storageKey) {
        this.storageKey = storageKey;
    }

    public Date getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Date timestamp) {
        this.timestamp = timestamp;
    }

    public Integer getPartsCount() {
        return partsCount;
    }

    public void setPartsCount(Integer partsCount) {
        this.partsCount = partsCount;
    }

    public String geteTag() {
        return eTag;
    }

    public void seteTag(String eTag) {
        this.eTag = eTag;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getDataBagId() {
        return dataBagId;
    }

    public void setDataBagId(String dataBagId) {
        this.dataBagId = dataBagId;
    }

    public String getCreator() {
        return creator;
    }

    public void setCreator(String creator) {
        this.creator = creator;
    }

    public String getUpdator() {
        return updator;
    }

    public void setUpdator(String updator) {
        this.updator = updator;
    }

    // public String getThumbnailUrl() {
    // return thumbnailUrl;
    // }
    //
    // public void setThumbnailUrl(String thumbnailUrl) {
    // this.thumbnailUrl = thumbnailUrl;
    // }

}
